import { weatherUrl } from '../config'
import fecth from '../util/fetch'
const key = '7b7b2605e91d46a19f1eaa79394435bc'

// 实时天气
const getWeatherNow = async (param) => {
  const res = await fecth.netFetch(weatherUrl + 'weather/now', 'GET', {
    location: param,
    key: key
  })
  return res.data
}

// 实时空气
const getAirNow = async (param) => {
  const res = await fecth.netFetch(weatherUrl + 'air/now', 'GET', {
    location: param,
    key: key
  })
  return res.data
}

// 七天天气预报
const getWeatherForecast = async (param) => {
  const res = await fecth.netFetch(weatherUrl + 'weather/forecast', 'GET', {
    location: param,
    key: key
  })
  return res.data
}

export default {
  getWeatherNow,
  getAirNow,
  getWeatherForecast
}
